using System;
using System.Collections.Generic;
using System.Text;
using PetShop.Infrastructure.Gateways;
using PetShop.Domain.Model;

namespace PetShop.Domain.Services
{
    public class OrderServices
    {
        private readonly OrderGateway _gateway;
        public OrderServices()
        {
            _gateway = new OrderGateway();
        }
        public void Register(Order aOrder)
        {
            //step 0
            aOrder.Validate();

          
            //step 1
            foreach (LineItemEntity orderLineItem in aOrder.LineItems)
            {
               orderLineItem.Item.InventoryQty = orderLineItem.Item.InventoryQty - orderLineItem.Quantity;
            }

             //step 2
            _gateway.Insert(aOrder);
        }

    }
}
